import pika
import sys

credentials = pika.PlainCredentials("guest", "guest")
conn_params = pika.ConnectionParameters("localhost",credentials=credentials)
conn_broker = pika.BlockingConnection(conn_params)
channel = conn_broker.channel()

channel.exchange_declare(exchange="alternate-exchange", 
                         exchange_type="fanout",
                         passive=False,
                         durable=False,
                         internal=True,
                         auto_delete=False)

channel.exchange_declare(exchange="backup_exchange",
                         exchange_type="direct",
                         passive=False,
                         durable=False,
                         internal=False,
                         auto_delete=False,
                         arguments={"alternate-exchange":"alternate-exchange"})

channel.queue_declare(queue="alternate-queue")
channel.queue_bind(queue="alternate-queue",exchange="alternate-exchange")

channel.queue_declare(queue="queue1")
channel.queue_bind(queue="queue1",exchange="backup_exchange",routing_key="backup")

routing_key = sys.argv[1]
channel.basic_publish(body="message",
                      exchange="backup_exchange",
                      routing_key=routing_key)

